package com.hzhr.iot.device.dao;

import com.hzhr.iot.device.dao.mapper.custom.CollectDeviceTypeEntityCustomMapper;
import com.hzhr.iot.device.dao.mapper.generator.CollectDeviceTypeEntityMapper;
import com.hzhr.iot.device.entity.CollectDeviceTypeEntity;
import com.hzhr.iot.device.entity.ext.CollectDeviceTypeEntityExt;
import com.hzhr.iot.device.queryModel.custom.CollectDeviceTypeCustomQueryModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class CollectDeviceTypeDao {
    @Autowired
    CollectDeviceTypeEntityMapper collectDeviceTypeEntityMapper;
    @Autowired
    CollectDeviceTypeEntityCustomMapper collectDeviceTypeEntityCustomMapper;

    public int insert(CollectDeviceTypeEntity record) {
        if (record == null) return 0;
        int changeCount = collectDeviceTypeEntityMapper.insert(record);
        return changeCount;
    }

    public int delete(CollectDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = collectDeviceTypeEntityCustomMapper.delete(queryModel);
        return changeCount;
    }

    public int update(CollectDeviceTypeEntity record) {
        if (record == null) return 0;
        int changeCount = collectDeviceTypeEntityMapper.updateByPrimaryKey(record);
        return changeCount;
    }

    public int updateProps(CollectDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = collectDeviceTypeEntityCustomMapper.updateProps(queryModel);
        return changeCount;
    }

    public CollectDeviceTypeEntity selectEntity(CollectDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceTypeEntityExt> extList = collectDeviceTypeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<CollectDeviceTypeEntity> selectEntityList(CollectDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceTypeEntityExt> extList = collectDeviceTypeEntityCustomMapper.selectExt(queryModel);
        if (extList == null) return null;
        List<CollectDeviceTypeEntity> entityList = new ArrayList<>();
        for (CollectDeviceTypeEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public CollectDeviceTypeEntityExt selectExt(CollectDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceTypeEntityExt> extList = collectDeviceTypeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<CollectDeviceTypeEntityExt> selectExtList(CollectDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceTypeEntityExt> extList = collectDeviceTypeEntityCustomMapper.selectExt(queryModel);
        return extList;
    }

    public CollectDeviceTypeEntity selectDesEntity(CollectDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceTypeEntityExt> extList = collectDeviceTypeEntityCustomMapper.selectDesExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<CollectDeviceTypeEntity> selectDesEntityList(CollectDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceTypeEntityExt> extList = collectDeviceTypeEntityCustomMapper.selectDesExt(queryModel);
        if (extList == null) return null;
        List<CollectDeviceTypeEntity> entityList = new ArrayList<>();
        for (CollectDeviceTypeEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public CollectDeviceTypeEntityExt selectDesExt(CollectDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceTypeEntityExt> extList = collectDeviceTypeEntityCustomMapper.selectDesExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<CollectDeviceTypeEntityExt> selectDesExtList(CollectDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceTypeEntityExt> extList = collectDeviceTypeEntityCustomMapper.selectDesExt(queryModel);
        return extList;
    }

    public int selectCount(CollectDeviceTypeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int count = collectDeviceTypeEntityCustomMapper.selectCount(queryModel);
        return count;
    }
}
